package com.example.a79273.shandianban.adapter;

import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.a79273.shandianban.R;
import com.example.a79273.shandianban.config.NetconfigYouHuo;
import com.example.a79273.shandianban.model.YouHuoProductTopImgsBean;
import com.jude.rollviewpager.adapter.StaticPagerAdapter;

import org.xutils.image.ImageOptions;
import org.xutils.x;

import java.util.List;

/**
 * Created by lenovo on 2016/8/30.
 */
public class YouHuoParticularsAdapter extends StaticPagerAdapter {
    private List<YouHuoProductTopImgsBean.DataBean.ListBean> mData;
    private ImageOptions mOptions;
    public YouHuoParticularsAdapter(List<YouHuoProductTopImgsBean.DataBean.ListBean> mData) {
        this.mData = mData;
        mOptions = new ImageOptions.Builder().setUseMemCache(true)
                .setLoadingDrawableId(R.mipmap.mr32)
                .setFailureDrawableId(R.mipmap.mr32).build();
    }

    @Override
    public View getView(ViewGroup container, int position) {
        ImageView view = new ImageView(container.getContext());
        String pic_scr_b = mData.get(position).getPic_scr_b();
        x.image().bind(view, NetconfigYouHuo.PIN_JIE+pic_scr_b,mOptions);
        view.setScaleType(ImageView.ScaleType.CENTER_CROP);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        return view;
    }

    @Override
    public int getCount() {
        return mData==null?0:mData.size();
    }

}
